package com.mkh.st.common.utils;

import java.util.Collection;
import java.util.Map;

/**
 * @Author yhj
 * @Date 2021/3/3
 **/
public final class Utils {
	public static boolean isEmpty(Map map) {
		return map == null || map.size() == 0;
	}

	public static boolean isNotEmpty(Map map) {
		return map != null && map.size() > 0;
	}

	public static boolean isEmpty(Collection collection) {
		return collection == null || collection.size() == 0;
	}

	public static boolean isNotEmpty(Collection collection) {
		return collection != null && collection.size() > 0;
	}

	public static boolean isEmpty(CharSequence sequence) {
		return isBlank(sequence);
	}

	public static boolean isNotEmpty(CharSequence sequence) {
		return !isBlank(sequence);
	}

	public static boolean isEmpty(Object[] array) {
		return array == null || array.length == 0;
	}

	public static boolean isNotEmpty(Object[] array) {
		return array != null && array.length > 0;
	}

	public static boolean isEmpty(byte[] array) {
		return array == null || array.length == 0;
	}

	public static boolean isNotEmpty(byte[] array) {
		return array != null && array.length > 0;
	}

	/**
	 * @param cs 字符串
	 * @return 是不是为空白字符串
	 */
	public static boolean isBlank(CharSequence cs) {
		int L;
		if (cs == null || (L = cs.length()) == 0) {
			return true;
		}
		for (int i = 0; i < L; i++) {
			if (!Character.isWhitespace(cs.charAt(i))) {
				return false;
			}
		}
		return true;
	}
}
